package thread

import java.lang.Exception

fun test() {
    println("test start time:${System.currentTimeMillis()}")
    try {
        Thread.sleep(4000)
    } catch (e: Exception) {
        println("test exception time:${System.currentTimeMillis()}")
        e.printStackTrace()
    }

    println("test end time:${System.currentTimeMillis()}")
}

fun main() {
    val thread = Thread {
        test()
    }
    thread.start()
    Thread.sleep(1000)
    //中断线程，结束线程
    thread.interrupt()
}